<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<!DOCTYPE html>
		<html lang="en">
		<head>
		    <meta charset="UTF-8">
		    <title>Title</title>
		</head>
		<body>
		<input type="checkbox" name="c">1<br>
		<input type="checkbox" name="c">2<br>
		<input type="checkbox" name="c">3<br>
		<input type="checkbox" name="c">4<br>
		<input type="checkbox" name="c">5<br>
		<input type="checkbox" name="c">6<br>
		<input type="checkbox" name="c">7<br>
		<hr>
		
		<input type="checkbox" id="xuan" onchange="a()">全选/全不选<br>
		<input type="button" id="fan" onclick="fan()" value="反选">
		
		<script>
		  function a() {
		    var stuts=document.getElementById("xuan").checked;
		    var c=document.getElementsByName("c");
		    for(var i=0;i<c.length;i++){
		        c[i].checked=stuts;
		    }
		  }
		  function fan() {
		    var stuts=document.getElementById("fan");
		    var c=document.getElementsByName("c");
		    for(var i=0;i<c.length;i++){
		      c[i].checked=!c[i].checked;
		    }
		  }
		</script>
		</body>
		</html>
	</body>
</html>
